#ifndef __SPI_TFTLCD_H__
#define __SPI_TFTLCD_H__

#include <linux/spi/spi.h>

#include "spi.h"

#define DEV_CNT         1
#define CHRDEV_NAME     "tftlcd"

#define ST7789          0

#if ST7789
#define LCD_WIDTH       240
#define LCD_HEIGHT      280
#else // ST7735
#define LCD_WIDTH       128
#define LCD_HEIGHT      160
#endif

struct spi_dev_node tftlcddev;

static int tftlcd_open(struct inode *, struct file *);
static ssize_t tftlcd_write(struct file *, char __user *, size_t, loff_t *);
static int tftlcd_release(struct inode *, struct file *);

static int tftlcd_probe(struct spi_device *);
static int tftlcd_remove(struct spi_device *);

static ssize_t tftlcd_writeCommand(u8);
//static ssize_t tftlcd_writeData(u8);
static ssize_t tftlcd_setCursor(int, int, int, int);
static int tftlcd_reset(struct spi_dev_node *);

static void tftlcd_clear(u8, u8);
static int tftlcd_init(void);

/* 总线设备注册 */
const struct spi_device_id lcd_device_id[] = {
    {"tftlcd,st7735s-spi", 0},
    {}
};

const struct of_device_id lcd_of_match[] = {
    { .compatible = "tftlcd,st7735s-spi" },
    { /* Sentinel */ }
};

static struct spi_driver tftlcd_driver = {
    .probe = tftlcd_probe,
    .remove = tftlcd_remove,
    .driver = {
        .owner = THIS_MODULE,
        .name = "st7735S_spi",
        .of_match_table = lcd_of_match,
    },
    .id_table = lcd_device_id,
};

#endif // __SPI_TFTLCD_H__
